import { LoveTaskBaseBody } from "./LoveTaskBaseBody";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { ObjCreate } from "../common/ObjCreate";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { Cache } from "../../cache/Cache";
import { ESex } from "../../../../Message/Public/ESex";
import { TaskProcessPanel } from "../task/imgtxt/TaskProcessPanel";
import { LoveTaskInviteList } from "./invitePanel/LoveTaskInviteList";
import { GScrollPane } from "../../../../com/mui/controls/GScrollPane";
import { ScrollPolicy } from "../../../../fl/controls/ScrollPolicy";
import { SPublicMiniPlayer } from "../../../../Message/Public/SPublicMiniPlayer";
import { GButton } from "../../../../com/mui/controls/GButton";
//class LoveTaskInvitePanel
    
    export  class LoveTaskInvitePanel extends LoveTaskBaseBody
    {
        constructor()
        {
            super();
            return;
        }

        /* internal  */invalidateList(): void
        {
            this._inviteList.invalidateList();
            this._scrollPane.refreshPane();
            this._scrollPane.update();
            return;
        }

        /* internal  */onCancalBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.LoveTaskInviteNoAll));
            return;
        }

        protected /* override */ initUI(): void
        {
            super.initUI();
            _titleTxt = ObjCreate.createTextField("", 0, 10, width, 100, this, _textFormat);
            _titleTxt.wordWrap = true;
            _titleTxt.multiline = true;
            _titleTxt.htmlText = HTMLUtil.addColor(Language.getStringByParam(21203, Cache.instance.role.entityInfo.sex != ESex._ESexMan ? Language.getString(21204) : Language.getString(21205), Cache.instance.loveTask.targetStr), "#F5BCBC");
            _titleTxt.addEventListener(flash.events.TextEvent.LINK, onTitleTxtLinkHandler);
            _bodyImg = new TaskProcessPanel();
            addChild(_bodyImg);
            _bodyImg.updateData(_titleTxt, null, false, onFlyGotoHandler, 1);
            this._inviteList = new LoveTaskInviteList();
            this._scrollPane = new GScrollPane();
            this._scrollPane.x = 0;
            this._scrollPane.y = _titleTxt.y + _titleTxt.textHeight + 0;
            this._scrollPane.width = width;
            this._scrollPane.height = height - this._scrollPane.y - 25;
            this._scrollPane.styleName = "GScrollPane";
            this._scrollPane.verticalScrollPolicy = ScrollPolicy.AUTO;
            this._scrollPane.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._scrollPane.source = this._inviteList;
            this._scrollPane.scrollDrag = false;
            this._scrollPane.focusEnabled = false;
            addChild(this._scrollPane);
            this._cancalBtn = ObjCreate.createGButton(Language.getString(21226), 0, 0, 74, 24, this, "ButtonGreenStyle");
            this._cancalBtn.y = height - 25;
            this._cancalBtn.x = (width - this._cancalBtn.width) / 2;
            this._cancalBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onCancalBtnClickHandler);
            return;
        }

        public /* override */ updateData(arg1: Array<any>=null): void
        {
            var loc1=0;
            var loc3=null;
            super.updateData(arg1);
            var loc2=arg1.length;
            while (loc1 < loc2) 
            {
                loc3 = arg1[loc1];
                this._inviteList.addItem(loc3);
                ++loc1;
            }
            this.invalidateList();
            this._scrollPane.verticalScrollPosition = 0;
            return;
        }

        public /* override */ addInvite(arg1: SPublicMiniPlayer): void
        {
            super.addInvite(arg1);
            this._inviteList.addItem(arg1);
            this.invalidateList();
            return;
        }

        public /* override */ delInviteView(arg1: SPublicMiniPlayer): void
        {
            super.delInviteView(arg1);
            this._inviteList.delItem(arg1);
            this.invalidateList();
            return;
        }

        public /* override */ dispose(): void
        {
            super.dispose();
            this._inviteList.dispose();
            return;
        }

        /* internal */ /* var */_cancalBtn: GButton;

        /* internal */ /* var */_inviteList: LoveTaskInviteList;

        /* internal */ /* var */_scrollPane: GScrollPane;
    }
